<div id="header"><?php
require './pages/blocks/menu.php';
?></div>
<?php
if (isset($_GET["page"])) {
	$page  = $_GET["page"];
}else{
	$page=1;
};
$start = ($page-1) * 10;
$news=NewsLists($start);
if(mysql_num_rows($news)){
	?>
	<?php
	while($row_news=mysql_fetch_array($news))
	{
		ob_start();
		?>
<div id="post">
<div id="post-content">
<div class="content">
<h2 class="category-text">Tin Tức</h2>
<ul class="category-list">
	<li>
	<h3 class="category-header">Lorem ipsum dolor sit amet, consectetur
	adipiscing elit</h3>
	<h4 class="category-date">Posted by Shun at 12:30 PM, 22/12/2012</h4>
	<img src="_images/image.jpg" alt="Post Image" class="category-image" />
	<div class="category-description">
	<p>{Summary}</p>
	<a class="category-readmore" href="#" title="">Read more...</a></div>
	</li>
</ul>
		<?php
		$full=explode(" ",$row_news["date_added"]);
		$rawdate=explode("-",$full[0]);
		$newdate = $rawdate[2]."/".$rawdate[1]."/".$rawdate[0];
		$date=$full[1]." ".$newdate;
		$s= ob_get_clean();
		$s=str_replace("{IDNews}",$row_news["new_id"],$s);
		$s=str_replace("{Title}",$row_news["title"],$s);
		$s=str_replace("{Summary}",$row_news["summary"],$s);
		$s=str_replace("{DatePosted}",$date,$s);
		$s=str_replace("{Image}",$row_news["image"],$s);
		$s=str_replace("{UserPosted}",$row_news["user_id"],$s);
		echo $s;
		?>
<div class="page"><?php
$qr="SELECT COUNT(new_id) from dt_news";
$result=mysql_query($qr);
$row_result=mysql_fetch_array($result);
$records=$row_result[0];
$total_pages=ceil($records/10);
if($total_pages>2){
	echo "Pages ";
	for ($i=1; $i<=$total_pages; $i++) {
		echo "<a href='index.php?p=newslistcp&page=".$i."'>".$i."</a> ";
	}
}?></div>
<?php
	}
}else{
	?>
<tbody>
	<tr>
		<td style="text-align: center" class="no-result" colspan="4"><?php echo "No Result!"; ?>
		</td>
	</tr>
</tbody>
	<?php }
	?></div>
</div>
<div id="widget"><?php
require './pages/blocks/widget.php';
?></div>
<div class="clear"></div>
</div>
<div id="footer"><?php
require './pages/blocks/footer.php';
?></div>
